import java.util.Arrays;

public class demo09 {
    public static void main(String[] args) {
        String str[] = {"AAA", "AAB", "AAA", "AAC", "AAC", "AAC", "BBC", "BBD", "AAC", "DBB", "AAE", "AAD"};
        int nullCount = 0;//记录重复元素的个数
        for (int i = 0; i < str.length; i++) {
            String target = str[i];
            if (target == null) continue;
            for (int j = i + 1; j < str.length; j++) {
                String current = str[j];
                if (current == null) continue;
                if (target.equals(current)) {
                    str[j] = null;
                    nullCount++;
                }
            }
        }

        String[] newStrs = new String[str.length - nullCount];
        int index = 0;
        for (int i = 0; i < str.length; i++) {
            if (str[i] == null) continue;
            newStrs[index++] = str[i];//将str数组中不为null的元素复制到新的数组中
        }

        System.out.println(Arrays.toString(newStrs));
    }
}
